# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1)

find_library( # Sets the name of the path variable.
        log-lib

        # Specifies the name of the NDK library that
        # you want CMake to locate.
        log)
set(distribution_DIR ${CMAKE_SOURCE_DIR}/libs)
message("CURRENT_DIR:" ${CMAKE_SOURCE_DIR})
add_library(
        avutil-54
        SHARED
        IMPORTED
)
set_target_properties(
        avutil-54
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libavutil-54.so
)
add_library(
        swresample-1
        SHARED
        IMPORTED)
set_target_properties(
        swresample-1
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libswresample-1.so
)
add_library(
        avcodec-56
        SHARED
        IMPORTED)
set_target_properties(
        avcodec-56
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libavcodec-56.so
)

add_library(
        avfilter-5
        SHARED
        IMPORTED)
set_target_properties(
        avfilter-5
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libavfilter-5.so
)

add_library(
        swscale-3
        SHARED
        IMPORTED)

set_target_properties(
        swscale-3
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libswscale-3.so
)

add_library(
        avdevice-56
        SHARED
        IMPORTED
)

set_target_properties(
        avdevice-56
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libavdevice-56.so
)


add_library(
        avformat-56
        SHARED
        IMPORTED
)

set_target_properties(
        avformat-56
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libavformat-56.so
)

add_library(
        postproc-53
        SHARED
        IMPORTED
)
set_target_properties(
        postproc-53
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libpostproc-53.so
)
add_library(
        yuv
        SHARED
        IMPORTED
)
set_target_properties(
        yuv
        PROPERTIES IMPORTED_LOCATION
        ${distribution_DIR}/${ANDROID_ABI}/libyuv.so
)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")

add_library( # Sets the name of the library.
        native-lib

        # Sets the library as a shared library.
        SHARED

        # Provides a relative path to your source file(s).
        src/main/cpp/native-lib.cpp)

include_directories(src/main/cpp/include)

target_link_libraries( # Specifies the target library.
        native-lib
        avcodec-56
        avdevice-56
        avfilter-5
        avformat-56
        avutil-54
        postproc-53
        swresample-1
        swscale-3
        yuv
        -landroid # Add this.
        ${log-lib}
        )